<template>
	<!-- 订单核销 -->
	<view class="content display  displayColumn">
		<u-navbar title="个人中心" @rightClick="rightClick" :autoBack="true" :placeholder="true">
			<view class="appoint_left display  " slot="left">
				<uni-icons type="left" size="20" color="#000"></uni-icons>
			</view>
			<view class="apponit_center display " slot="center">
				<span class="title_txt fontSize font_comm">订单核销</span>
			</view>
		</u-navbar>
		<!-- 核销列表 -->
		<view class="width-100 display  displayColumn wode_card all_item" v-for="(item,index) in infoArr" :key="index" @click.stop="chakandetails(item.id)">
			<compage @backHome.stop="backHome" :item="item"></compage>
		</view>
		<view class="display width-100 all_item" style="height: 100rpx;">
			<u-loading-icon text="加载中" textSize="10" :show="show" ></u-loading-icon>
		</view>
	</view>
</template>
<script>
	import compage from './compage1.vue'
	export default {
		components: {
			compage
		},
		data() {
			return {
				userInfo:{},//用户信息
				infoArr:[],//列表
				show:false,
				page:1,
				code:'',
				flag:true
			}
		},
		watch:{
			code(newval,oldvalue){
				this.flag = false
			}
		},
		onLoad(options) {
			// 获取用户信息
			this.userInfo = uni.getStorageSync('userInfo')
			// console.log(this.userInfo)/
			if(!uni.$u.test.isEmpty(options.code)){
				this.code = options.code;
				
					this.getcodeList();
				
				console.log(this.code)
			}
		},
		onReady() {
			// 获取订单列表
			this.$modal.loading('正在加载')
			if(uni.$u.test.isEmpty(this.code)){
				
				this.getList();
			}
			
		},
		// 监听页面滚动到底部
		async onReachBottom() {
					if(uni.$u.test.isEmpty(this.code)){
						console.log("onReachBottom");
						this.show = true;
						this.getList(this.page++)
					}
				},
		methods: {
			// 查看详情
			chakandetails(id){
				this.$tab.navigateTo(`/packageB/orderDetails/orderDetails?id=${id}`)
			},
			// 初始化菜单
			backHome(){
				if(uni.$u.test.isEmpty(this.code)){
					this.page = 1;
					console.log('测试')
					this.infoArr = []
					this.getList();
				}else{
					this.getcodeList();
				}
			
				
			},
			getcodeList(){
				this.$req.get(`/xcx/orderReservation/getInfo/code/${this.code}`).then(res=>{
					console.log(res)
					this.$modal.closeLoading();
					if(res.data.code==200){
						let x= [];
						x.push(res.data.data)
						this.infoArr = x;
						console.log(this.infoArr)
					}else{
						this.$modal.msg(res.data.msg)
					}
					
				})
			},
			getList(){
				// console.log(this.userInfo)
				let data = {
					userId:this.userInfo.user.userId,//：用户id（用户查询用），
					stationId:'',//：（洗车站站长查询用），
					workerId:'',//技工师傅id
					pageSize:10,
					pageNum:this.page
				}
				this.$req.get('/xcx/orderReservation/list',data).then(res=>{
					console.log(res)
					if(res.data.rows.length ==0){
						this.show = false;
						return
					}
					this.$modal.closeLoading();
					if(res.data.code==200){
						this.infoArr = this.infoArr.concat(res.data.rows);
						// console.log(this.infoArr)
						this.show = false
					}else{
						this.$modal.msg(res.data.msg||'请求失败');
						this.show = false
					}
				})
			}
		}
	}
</script>
<style>
	page {
		background: #F4F5FA;
	}
</style>
<style scoped lang="scss">
	.content {
		width: 100%;
		min-height: 100vh;
	}
	.title_txt {
		font-size: 32rpx;
		font-weight: 600;
		color: #212121;
	}
	.wode_card {
		// min-height: 400rpx;
	}
</style>